package test.infinispan;

import java.io.Serializable;

import javax.annotation.PostConstruct;
import javax.annotation.Resource;
import javax.enterprise.context.RequestScoped;
import javax.inject.Named;

import org.infinispan.Cache;
import org.infinispan.manager.EmbeddedCacheManager;

@Named("indexBean")
@RequestScoped
public class IndexController implements Serializable {

	private static final long serialVersionUID = 5983206217118223542L;

	private String msg = "abc";

	@Resource(lookup = "java:jboss/infinispan/container/ocelot")
	private EmbeddedCacheManager cacheManager;

	private Cache<Object, Object> cache;

	@PostConstruct
	private void init() {
		cache = cacheManager.getCache("carcache");
		cache.put("a", 1);

		System.out.println(cache.get("a"));
	}

	public String getMsg() {
		return msg;
	}

	public void setMsg(String msg) {
		this.msg = msg;
	}

}